package com.weiaibenpao.demo.chislim.util;

import android.content.Context;
import android.content.DialogInterface;
import android.support.v7.app.AlertDialog;

/**
 * Created by lenovo on 2017/9/13.
 */

public class SportAlertDialogUtil {


    //进入app弹框提示，必须使用启迈斯跑步机
    public static void  showAppIsQMSDialog(Context context){
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("提示");
        builder.setMessage("室内跑步必须使用蓝牙连接启迈斯跑步机");
        /*builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                //do nothing
            }
        });*/
        builder.setPositiveButton("我知道了", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {

            }
        });
        builder.setCancelable(false);
        builder.show();
    }

    public void  showNotUploadDialog(Context context){
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("跑步提示");
        builder.setMessage("本次跑步距离太短，无法保存，确定放弃？");
        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                onListen.abandon();
            }
        });
        builder.setCancelable(false);
        builder.show();
    }

    public void showUploadDialog(Context context){
        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setTitle("跑步提示");
        builder.setMessage("是否保存并上传数据？");
        builder.setNegativeButton("放弃", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                onListen.abandon();
            }
        });
        builder.setPositiveButton("保存", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                onListen.okCommit();
            }
        });
        builder.setCancelable(false);
        builder.show();
    }



    public interface OnListen{
        void cancle();
        void okCommit();
        void abandon();
    }

    private OnListen onListen;             //music对象

    //定义接口入住对象
    public void setOnListener(OnListen onListen){
        this.onListen = onListen;
    }
}
